using System.Collections.Generic;
using Gameplay.PVE.Config;
using UnityEngine;
using Yoozoo.Managers;

namespace Gameplay.PVE
{
    public class ImmuneElement : ElementBase
    {
        private int elementImmune;
        
        public override void Execute()
        {
            base.Execute();
            /*int controlType = GetValue("ControlType");
            if (controlType == 1) //说明释放时施加驱散
            {
                elementImmune = GetValue("ElementImmune");
                RemoveElementArg arg = ClassManager.Get<RemoveElementArg>();
                arg.removeType = elementImmune;
                target.Transmit(ETransmitType.RemoveElement,arg);
                ClassManager.Free(arg);
            }*/
            int immuneType = GetValue("ImmuneType");
            if (immuneType == 100) //无敌
            {
                target.Data.invulnerableList.Add(this);
            }
            else if (immuneType == 101) //不受其他技能控制
            {
                target.Data.controlable = false;
            }
        }

        public override EElementExistType GetExistType(PveSkillElementConfig newConfig)
        {
            if ((newConfig.buff_type & elementImmune) > 0)
            {
                return EElementExistType.Filter;
            }
            return base.GetExistType(newConfig);
        }


        public override void Free()
        {
            int immuneType = GetValue("ImmuneType");
            if (immuneType == 100) //无敌
            {
                target.Data.invulnerableList.Remove(this);
            }
            else if (immuneType == 101) //不受其他技能控制
            {
                target.Data.controlable = true;
            }
            base.Free();
        }
    }
}